from huibian2jiqi import HuiBian2JiQi as HJ
from yufa_iter import 递归语法分析器 as IY


if __name__=="__main__":
    print("编译M语言结构体:")
    src_hb="放15入A;放15到B ;放15到BX;"
    #src_m="组花量等1行花行"
    src_m="组{i=1;j=3;};"
    print("源代码为:\n%s"%(src_m))
    hj=HJ(src=src_m)
    T = hj.getToken()
    hj.tokens=hj.tokens+T
    while T != "未":
        T = hj.getToken()
        hj.tokens=hj.tokens+T
    print("词法分析:")
    print(hj.tokens)    
    print("提取到的数:")
    print(hj.nums)

    tokensr=list(hj.tokens[::-1])
    #hj.run()
    nums=hj.nums[::-1]
    iy=IY(64,nums)
    if iy.开分析(T=tokensr):
        print("得到的汇编码:")
        print(iy.MC)
    else:
        print("遇到错误")
    
    hj1=HJ(src=iy.MC)
    print("得到的机器码:")
    hj1.run()
